package com.xyy.yueshijia.base;

import com.xyy.yueshijia.bean.BaseBean;

import rx.Subscriber;


/**
 * Created by lxs on 2017/2/7.
 */
public abstract class BaseSubscriber<T> extends Subscriber<BaseBean<T>> {

    @Override
    public void onCompleted() {
        onFinish();
    }

    @Override
    public void onNext(BaseBean<T> tBaseBean) {

        if (tBaseBean.getCode() == 200) {
            onSuccess(tBaseBean.getDatas());

        } else {

        }
        onFinish();
    }

    @Override
    public void onError(Throwable e) {
        onFail(e);
        onFinish();
    }

    //成功
    public abstract void onSuccess(T t);

    //失败
    public abstract void onFail(Throwable e);

    //结束
    public abstract void onFinish();
}
